import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class User {
  @PrimaryGeneratedColumn('uuid')
  uid: string;

  @Column({
    type: 'varchar',
    nullable: false,
    length: 100,
  })
  name: string;

  @Column({
    type: 'varchar',
    nullable: false,
    length: 100,
  })
  email: string;

  @Column({
    type: 'varchar',
    nullable: false,
    length: 100,
  })
  password: string;

  @Column({
    type: 'varchar',
    nullable: true,
  })
  avatar: string;

  @Column({
    type: 'varchar',
    nullable: true,
  })
  sex: string;

  @CreateDateColumn({
    type: 'datetime',
    name: 'create_at',
    nullable: true,
  })
  createAt: Date;

  @UpdateDateColumn({
    type: 'datetime',
    name: 'update_at',
    nullable: true,
  })
  updateAt: Date;
}

export class UserDto {
  uid: string;
  name: string;
  email: string;
  password: string;
  avatar: string | null;
  sex: string | null;
  createdAt: Date | null;
  updatedAt: Date | null;
}
